/**
 * 
 */
package com.axxc.jpa.service.impl;

import org.springframework.cache.annotation.Cacheable;
import org.springframework.data.jpa.domain.Specification;
import org.springframework.stereotype.Service;

import com.axxc.jpa.entity.VisitLogEntity;
import com.axxc.jpa.out.filter.VisitLogFilter;
import com.axxc.jpa.out.model.VisitLog;
import com.axxc.jpa.service.AbstractCRUDService;
import com.axxc.jpa.service.IVisitLogService;
import com.axxc.jpa.specification.VisitLogSpec;

/**
 * @ClassName: VisitLogServiceImpl
 * @Description: TODO(这里用一句话描述这个类的作用)
 * @author 熊小川
 * @date 2018年6月6日 下午10:09:05
 * @See
 */
@Service
public class VisitLogServiceImpl extends AbstractCRUDService<VisitLog, VisitLogEntity, VisitLogFilter, Long>
		implements IVisitLogService {

	@Override
	protected VisitLogEntity toEntity(VisitLog visitLog) {
		return visitLog.toEntity();
	}

	@Override
	protected VisitLog toModel(VisitLogEntity visitLogEntity) {
		return visitLogEntity.toModel();
	}

	@Override
	protected Specification<VisitLogEntity> toFilter(VisitLogFilter filter) {
		return new VisitLogSpec(filter);
	}

	@Override
	@Cacheable(key = "#id", value = "VisitLogEntity")
	public VisitLogEntity findOneById(Long id) {
		logger.info("缓存不存在,查询数据库.ID为" + id);
		return this.repository.findOne(id);
	}

	@Override
	public VisitLogEntity save(VisitLogEntity visitLogEntity) {
		// TODO Auto-generated method stub
		return this.repository.save(visitLogEntity);
	}

}
